home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Tool Chest / Testing & Debugging / Debuggers & dcmds / MacsBug 6.6 / Building dcmds / dcmd Includes / Dcmd.a next >
Encoding:
Text File  |  1999-10-20  |  9.8 KB  |  357 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        dcmd.a
  3. ;
  4. ;    Contains:    MacsBug debugger command interface.
  5. ;
  6. ;    Version:    Technology:    MacsBug
  7. ;                Release:    MacsBug 6.6
  8. ;
  9. ;    Copyright:    © 1988, 1994-1999, 1999 by Apple Computer, Inc., All Rights Reserved.
  10. ;
  11. ;    Bugs?:        For bug reports, consult the following page on
  12. ;                the World Wide Web:
  13. ;
  14. ;                    http://developer.apple.com/bugreporter/
  15. ;
  16. ;
  17.     IF &TYPE('__DCMD__') = 'UNDEFINED' THEN
  18. __DCMD__ SET 1
  19.  
  20.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  21.     include 'MacTypes.a'
  22.     ENDIF
  23.     IF &TYPE('__MACHINEEXCEPTIONS__') = 'UNDEFINED' THEN
  24.     include 'MachineExceptions.a'
  25.     ENDIF
  26.  
  27. ;  Possible requests from the debugger to the command
  28.  
  29. dcmdInit                        EQU        0                    ; Initialize the Dcmd 
  30. dcmdDoIt                        EQU        1                    ; Normal Dcmd execution 
  31. dcmdHelp                        EQU        2                    ; Display help for Dcmd 
  32.                                                             ; Requests added to MacsBug in 6.5d10 that are only sent to format 3 or newer dcmds. 
  33. dcmdSecondaryInit                EQU        3                    ; Second time to init after all System patches have been loaded 
  34. dcmdShutdown                    EQU        4                    ; Dcmd should remove any patches (if possible) 
  35. dcmdGetInfo                        EQU        5                    ; Return dcmd version and pointer to help text 
  36.  
  37. ;  68K register file indices into the RegisterFile.
  38.  
  39. D0Register                        EQU        0
  40. D1Register                        EQU        1
  41. D2Register                        EQU        2
  42. D3Register                        EQU        3
  43. D4Register                        EQU        4
  44. D5Register                        EQU        5
  45. D6Register                        EQU        6
  46. D7Register                        EQU        7
  47. A0Register                        EQU        8
  48. A1Register                        EQU        9
  49. A2Register                        EQU        10
  50. A3Register                        EQU        11
  51. A4Register                        EQU        12
  52. A5Register                        EQU        13
  53. A6Register                        EQU        14
  54. A7Register                        EQU        15
  55. PCRegister                        EQU        16
  56. SRRegister                        EQU        17                    ; SR is only 16 bits and is stored in the high word 
  57.  
  58. ;  Heap block types
  59.  
  60. freeBlock                        EQU        0
  61. nonrelocatableBlock                EQU        1
  62. relocatableBlock                EQU        2
  63.  
  64. ;     The format of the 68K registers passed to the dcmd.
  65. RegisterFile            RECORD 0
  66. elements                 ds.l    18
  67. sizeof                     EQU *                    ; size:   $48 (72)
  68.                         ENDR
  69.  
  70.  
  71. ; typedef long *                        RegisterFilePtr
  72.  
  73.  
  74. ;  Structure used to pass information to and from the dcmd.
  75. dcmdBlock                RECORD 0
  76. registerFile             ds.l    1                ; offset: $0 (0)        ;  pointer to 68K CPU register set 
  77. request                     ds.w    1                ; offset: $4 (4)        ;  what action we are requested to take 
  78. aborted                     ds.b    1                ; offset: $6 (6)        ;  Set to true if the user types a key while scrolling 
  79. pad1                     ds.b    1                ; offset: $7 (7)        ;  align to word boundary 
  80. macsBugVersion             ds.l    1                ; offset: $8 (8)        ;  version of MacsBug we are running under 
  81. maxCallback                 ds.w    1                ; offset: $C (12)        ;  maximum valid callback we can make 
  82. currentISA                 ds.b    1                ; offset: $E (14)        ;  ISA of current PC 
  83. pad2                     ds.b    1                ; offset: $F (15)        ;  align to word boundary 
  84. theException             ds.l    1                ; offset: $10 (16)        ;  Pointer to PowerPC machine state if ISA is PowerPC 
  85. requestIOBlock             ds.l    1                ; offset: $14 (20)        ;  general-purpose input/output data block pointer 
  86. sizeof                     EQU *                    ; size:   $18 (24)
  87.                         ENDR
  88. ; typedef struct dcmdBlock *            dcmdBlockPtr
  89.  
  90.  
  91. GetInfoRequestBlock        RECORD 0
  92. usageStr                 ds        Str255            ; offset: $0 (0)
  93. creditsStr                 ds        Str255            ; offset: $100 (256)
  94. dcmdVersion                 ds        NumVersion        ; offset: $200 (512)
  95. sizeof                     EQU *                    ; size:   $204 (516)
  96.                         ENDR
  97. ; typedef struct GetInfoRequestBlock *    GetInfoRequestBlockPtr
  98.  
  99.  
  100. ;    MacsBug callback routines that can be called by the dcmd.
  101.  
  102.  
  103. ;    Draw the text in the Pascal string as one or more lines separated by CR's.
  104. ;    Each line causes the MacsBug display to be scrolled and the new line to be
  105. ;    drawn at the bottom. If the user types a key while scrolling then the aborted
  106. ;    flag is set telling the command to terminate immediately.
  107.  
  108. ;
  109. ; pascal void dcmdDrawLine(ConstStr255Param str)
  110. ;
  111.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  112.         IMPORT_CFM_FUNCTION dcmdDrawLine
  113.     ENDIF
  114.  
  115.  
  116. ;    Draw the text in the Pascal string as a continuation of the current line.
  117. ;    CR's are not given special treatment.
  118.  
  119. ;
  120. ; pascal void dcmdDrawString(ConstStr255Param str)
  121. ;
  122.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  123.         IMPORT_CFM_FUNCTION dcmdDrawString
  124.     ENDIF
  125.  
  126.  
  127. ;    Draw a given number of characters starting from the given pointer as a 
  128. ;    continuation of the current line. CR's are not given special treatment.
  129.  
  130. ;
  131. ; pascal void dcmdDrawText(char *text, short length)
  132. ;
  133.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  134.         IMPORT_CFM_FUNCTION dcmdDrawText
  135.     ENDIF
  136.  
  137.  
  138. ;    Scrolls the MacsBug display up one line leaving a blank line at the bottom.
  139.  
  140. ;
  141. ; pascal void dcmdScroll(void )
  142. ;
  143.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  144.         IMPORT_CFM_FUNCTION dcmdScroll
  145.     ENDIF
  146.  
  147.  
  148. ;    Display the Pascal string in the command line area and wait for a key to be pressed.
  149. ;    Return TRUE if the user typed Return. All other keys return FALSE. MacsBug saves this
  150. ;    key and adds it to the command line once the current command completes. Typing any
  151. ;    key other than Return sets the aborted flag and tells the command to terminate immediately.
  152.  
  153. ;
  154. ; pascal Boolean dcmdDrawPrompt(ConstStr255Param str)
  155. ;
  156.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  157.         IMPORT_CFM_FUNCTION dcmdDrawPrompt
  158.     ENDIF
  159.  
  160.  
  161. ;    Get the current command line position.
  162.  
  163. ;
  164. ; pascal short dcmdGetPosition(void )
  165. ;
  166.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  167.         IMPORT_CFM_FUNCTION dcmdGetPosition
  168.     ENDIF
  169.  
  170.  
  171. ;    Set the current command line position. This should only be set to a value returned 
  172. ;    by dcmdGetPosition.
  173.  
  174. ;
  175. ; pascal void dcmdSetPosition(short pos)
  176. ;
  177.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  178.         IMPORT_CFM_FUNCTION dcmdSetPosition
  179.     ENDIF
  180.  
  181.  
  182. ;    Return the next character on the command line or CR if the entire line has been scanned
  183.  
  184. ;
  185. ; pascal short dcmdGetNextChar(void )
  186. ;
  187.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  188.         IMPORT_CFM_FUNCTION dcmdGetNextChar
  189.     ENDIF
  190.  
  191.  
  192. ;    Return the next character on the command line or CR if the entire line has been scanned.
  193. ;    However, the current command line position is not changed.
  194.  
  195. ;
  196. ; pascal short dcmdPeekAtNextChar(void )
  197. ;
  198.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  199.         IMPORT_CFM_FUNCTION dcmdPeekAtNextChar
  200.     ENDIF
  201.  
  202.  
  203. ;    Copy all characters from the command line to the parameter string until a delimiter
  204. ;    is found or the end of the command line is reached. A delimiter is either a space,
  205. ;    a comma or a CR. Both single and double quoted strings are allowed on the command
  206. ;    line. However, the leading and trailing quotes must be of the same type. The parameter
  207. ;    string is returned without the quotes. This function returns the delimiter.
  208.  
  209. ;
  210. ; pascal short dcmdGetNextParameter(Str255 str)
  211. ;
  212.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  213.         IMPORT_CFM_FUNCTION dcmdGetNextParameter
  214.     ENDIF
  215.  
  216.  
  217. ;    Parse the command line for the next expression. All expressions are evaluated to 32 bits.
  218. ;    This function returns the delimiter after the expression. The possible delimiters are
  219. ;    space, comma and CR. Space is not treated as a delimiter in the middle of expressions,
  220. ;    unless it's before a binary '-' (minus). For instance, '1 + 2' will return a value of 3
  221. ;    and the delimiter will be the char following the 2. '1 - 2' will return a value of 1
  222. ;    and the delimeter is the space character before the '-'. This is done so that built-in
  223. ;    commands and dcmds can properly parse '-x' options. The return parameter 'ok' tells if
  224. ;    the expression was parsed successfully as far as syntax is concerned.
  225.  
  226. ;
  227. ; pascal short dcmdGetNextExpression(long *value, Boolean *ok)
  228. ;
  229.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  230.         IMPORT_CFM_FUNCTION dcmdGetNextExpression
  231.     ENDIF
  232.  
  233.  
  234. ;    Copy the break message MacsBug displayed the last time it was entered into str.
  235. ;    This may contain multiple lines separated by CR's.
  236.  
  237. ;
  238. ; pascal void dcmdGetBreakMessage(Str255 str)
  239. ;
  240.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  241.         IMPORT_CFM_FUNCTION dcmdGetBreakMessage
  242.     ENDIF
  243.  
  244.  
  245. ;    Return a symbolic representation for address in str. If no symbol can be found
  246. ;    then an empty string is returned. The format of the symbol returned is Name+00000.
  247.  
  248. ;
  249. ; pascal void dcmdGetNameAndOffset(long address, Str255 str)
  250. ;
  251.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  252.         IMPORT_CFM_FUNCTION dcmdGetNameAndOffset
  253.     ENDIF
  254.  
  255.  
  256. ;    Return the trap name for the trap number. If no symbol can be found
  257. ;    then an empty string is returned.
  258.  
  259. ;
  260. ; pascal void dcmdGetTrapName(short trapNumber, Str255 trapName)
  261. ;
  262.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  263.         IMPORT_CFM_FUNCTION dcmdGetTrapName
  264.     ENDIF
  265.  
  266.  
  267. ;    Return a pointer the macro name for the given value. If no macro can be found
  268. ;    then a nil is returned.
  269.  
  270. ;
  271. ; pascal StringPtr dcmdGetMacroName(long value)
  272. ;
  273.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  274.         IMPORT_CFM_FUNCTION dcmdGetMacroName
  275.     ENDIF
  276.  
  277.  
  278. ;    When a debugger command is called, the debugger's world (low memory) is installed.
  279. ;    Commands that want to reference the user's world can swap back and forth between the
  280. ;    two worlds by making this call. This procedure does nothing in MacsBug; there is no
  281. ;    distinction between user and debugger worlds. It is included to support other
  282. ;    debuggers that might want to take advantage of it.
  283.  
  284. ;
  285. ; pascal void dcmdSwapWorlds(void )
  286. ;
  287.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  288.         IMPORT_CFM_FUNCTION dcmdSwapWorlds
  289.     ENDIF
  290.  
  291.  
  292. ;    Toggle between the user and debugger displays. The first call restores the user's actual screen.
  293. ;    The second call restores the debugger's screen.
  294.  
  295. ;
  296. ; pascal void dcmdSwapScreens(void )
  297. ;
  298.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  299.         IMPORT_CFM_FUNCTION dcmdSwapScreens
  300.     ENDIF
  301.  
  302.  
  303. ;    Walk through the blocks in the current heap, calling DoThis for each block.
  304. ;    The blockAddress and blockLength pertain to the data in the heap block, not including
  305. ;    the block header. The addrOfMasterPtr is the master pointer's location in the heap,
  306. ;    not the value of the master ptr. The blockType is defined by the constants freeBlock,
  307. ;    nonrelocatableBlock and relocatableBlock. The booleans locked, purgeable and resource
  308. ;    reflect the state of the block.
  309.  
  310. ;
  311. ; pascal void dcmdForAllHeapBlocks(DoThisPtr DoThis)
  312. ;
  313.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  314.         IMPORT_CFM_FUNCTION dcmdForAllHeapBlocks
  315.     ENDIF
  316.  
  317.     ENDIF ; __DCMD__ 
  318.  
  319.